package elevatronic.view.right.parameter;

import javax.swing.JLabel;

import elevatronic.view.MPanel;



/**
 * 
 * @author Benjamin CORNEC
 * it's the place where we can change the speed of the simulation
 *
 */
public class ParameterPanel extends MPanel {
	private static final long serialVersionUID = 3023315736007297599L;

	private static final int WIDTH_DELAY=100;
	private static final int HEIGHT_DELAY=30;
	private static final int WIDTH_STEP=100;
	private static final int HEIGHT_STEP=30;
	private static final int POSX_SLIDERS=17;

	//control used to manage the step
	private SpeedSliderView speedSliderStep;
	public SpeedSliderView getSpeedSliderStep() {
		return speedSliderStep;
	}
	public void setSpeedSliderStep(SpeedSliderView speedSliderStep) {
		this.speedSliderStep = speedSliderStep;
	}
	

	//control used to manage the delay
	private SpeedSliderView speedSliderDelay;
	public SpeedSliderView getSpeedSliderDelay() {
		return speedSliderDelay;
	}
	public void setSpeedSliderDelay(SpeedSliderView speedSliderDelay) {
		this.speedSliderDelay = speedSliderDelay;
	}
	
	
	//label of delay
	private JLabel delayLabel;
	public JLabel getDelayLabel() {
		if (delayLabel==null){
			delayLabel=new JLabel("Delay : ");
		}
		return delayLabel;
	}
	public void setDelayLabel(JLabel delayLabel) {
		this.delayLabel = delayLabel;
	}
	
	
	//value of delay
	public int getDelayValue() {
		return ((SpeedSliderDelayView)getSpeedSliderDelay()).getDelayValue();
	}
	

	//label of step
	private JLabel stepLabel;
	public JLabel getStepLabel() {
		if (stepLabel==null){
			stepLabel=new JLabel("Step : ");
		}
		return stepLabel;
	}
	public void setStepLabel(JLabel stepLabel) {
		this.stepLabel = stepLabel;
	}

	public int getStepValue() {
		return ((SpeedSliderStepView)getSpeedSliderStep()).getStepValue();
	}


	/**
	 * Constructor
	 */
	public ParameterPanel(int wdth,int hght){
		super(wdth,hght);
		getDelayLabel().setBounds(5, 20,200,HEIGHT_DELAY);
		getStepLabel().setBounds(5, 100,200,HEIGHT_STEP);
		
		setSpeedSliderDelay(new SpeedSliderDelayView(WIDTH_DELAY,HEIGHT_DELAY));
		setSpeedSliderStep(new SpeedSliderStepView(WIDTH_STEP,HEIGHT_STEP));
		getSpeedSliderDelay().setLocation(POSX_SLIDERS, 60);
		getSpeedSliderStep().setLocation(POSX_SLIDERS, 140);


		add(getSpeedSliderDelay());
		add(getSpeedSliderStep());
		add(getDelayLabel());
		add(getStepLabel());
		

	}
	
	
	//iteration of the parameter panel
	public void update(int step){
		super.update(step);
		getDelayLabel().setText("Delay: "+getDelayValue()+"ms betw 2 cycles");
		getStepLabel().setText("Step: "+getStepValue()+" acts per cycle");
	}

}
